//
//  DoorListCell.m
//  RONGAO
//
//  Created by wei wang on 2017/7/5.
//  Copyright © 2017年 wei wang. All rights reserved.
//

#import "DoorListCell.h"

NSString *const KDoorListCellIdentifer = @"KDoorListCellIdentifer";

@implementation DoorListCell

+ (instancetype)dequeueReusableWithTableView:(UITableView *)tableView{
    
    DoorListCell *cell = [tableView dequeueReusableCellWithIdentifier:KDoorListCellIdentifer];
    if (cell == nil) {
        
        cell = [[DoorListCell alloc] init];
        
    }
    return cell;
}

- (instancetype)init
{
    self = [super initWithStyle:UITableViewCellStyleDefault reuseIdentifier:KDoorListCellIdentifer];
    if (self)
    {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.backgroundColor = [UIColor clearColor];
        [self masLayoutSubview];
    }
    return self;
}

- (void)masLayoutSubview
{
    __weak UIView *superView = self;
    [self.deviceNameLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
       
        make.centerY.mas_equalTo(superView.mas_centerY);
        make.left.mas_equalTo(superView.mas_left).mas_offset(20);
        
    }];
    
    [self.stautsBtn mas_remakeConstraints:^(MASConstraintMaker *make) {
       
        make.centerY.mas_equalTo(superView.mas_centerY);
        make.right.mas_equalTo(superView.mas_right).mas_offset(-20);
        
    }];
    
    [self.stautsBtn layoutButtonWithEdgeInsetsStyle:MKButtonEdgeInsetsStyleLeft imageTitleSpace:8];

}

- (UILabel *)deviceNameLabel{
    
    if (!_deviceNameLabel) {
        
        _deviceNameLabel = [[UILabel alloc] init];
        [_deviceNameLabel setFont:[UIFont systemFontOfSize:14.f]];
        _deviceNameLabel.textColor = [UIColor colorWithHexString:@"666666"];
        [self addSubview:_deviceNameLabel];
        
    }
    return _deviceNameLabel;
}

- (UIButton *)stautsBtn{
    
    if (!_stautsBtn) {
        
        _stautsBtn = [[UIButton alloc] init];
        [_stautsBtn setTitle:@"离线" forState:UIControlStateNormal];
        [_stautsBtn setTitle:@"在线" forState:UIControlStateSelected];
        [_stautsBtn setImage:[UIImage imageNamed:@"offline"] forState:UIControlStateNormal];
        [_stautsBtn setImage:[UIImage imageNamed:@"online"] forState:UIControlStateSelected];
        [_stautsBtn.titleLabel setFont:[UIFont systemFontOfSize:13.f]];
        [_stautsBtn setTitleColor:[UIColor colorWithHexString:@"aaa7a6"] forState:UIControlStateNormal];
        [_stautsBtn setTitleColor:[UIColor colorWithHexString:@"75706f"] forState:UIControlStateSelected];
        [self addSubview:_stautsBtn];

    }
    return _stautsBtn;
}


- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
